package com.demo.validator;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

public class LoginValidator extends Validator{

	@Override
	protected void validate(Controller c) {
		validateRequiredString("username", "Msg", "请输入用户名!");
		validateRequiredString("password", "Msg", "请输入密码!");
		
	}

	@Override
	protected void handleError(Controller controller) {
		String actionKey = getActionKey();
		if (actionKey.equals("/admin/login/checkLogin")){
			controller.keepPara("username", "password");
			controller.render("/page/admin/login.html");
		}else{
			controller.render("/page/admin/login.html");
		}
		
	}

}
